From: Matthieu Gallien Date: Mon, 31 Mar 2025 09:59:37 +0000 (+0200) Subject: only send the md5 custom checksum header when server expects it X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2^2~38^2 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com///%22http:/www.example.com/cgi/%22https:/www.github.com/?a=commitdiff_plain;h=ec0e2d6ce01e2c7a7999ecda7fd3ae0f97790a38;p=nextcloud-desktop.git only send the md5 custom checksum header when server expects it server before 32.0.0 release expects a custom header with an MD5 checksum during bulk upload the header name is: X-File-MD5 see https://github.com/nextcloud/server/pull/51729 Signed-off-by: Matthieu Gallien --- diff --git a/src/libsync/account.cpp b/src/libsync/account.cpp index b1fb5a2f4..fc7af4d1e 100644 --- a/src/libsync/account.cpp +++ b/src/libsync/account.cpp @@ -796,6 +796,11 @@ int Account::checksumRecalculateServerVersionMinSupportedMajor() const return checksumRecalculateRequestServerVersionMinSupportedMajor; } +bool Account::bulkUploadNeedsLegacyChecksumHeader() const +{ + return serverVersionInt() < makeServerVersion(32, 0, 0); +} + void Account::setServerVersion(const QString &version) { if (version == _serverVersion) { diff --git a/src/libsync/account.h b/src/libsync/account.h index eddb77c90..49d9d20e5 100644 --- a/src/libsync/account.h +++ b/src/libsync/account.h @@ -307,6 +307,8 @@ public: [[nodiscard]] int checksumRecalculateServerVersionMinSupportedMajor() const; + [[nodiscard]] bool bulkUploadNeedsLegacyChecksumHeader() const; + /** True when the server connection is using HTTP2 */ bool isHttp2Supported() { return _http2Supported; } void setHttp2Supported(bool value) { _http2Supported = value; } diff --git a/src/libsync/bulkpropagatorjob.cpp b/src/libsync/bulkpropagatorjob.cpp index 9cb799633..7e2154198 100644 --- a/src/libsync/bulkpropagatorjob.cpp +++ b/src/libsync/bulkpropagatorjob.cpp @@ -188,7 +188,9 @@ void BulkPropagatorJob::doStartUpload(SyncFileItemPtr item, const auto remotePath = propagator()->fullRemotePath(fileToUpload._file); - currentHeaders["X-File-MD5"] = md5ChecksumHeader; + if (!md5ChecksumHeader.isEmpty()) { + currentHeaders["X-File-MD5"] = md5ChecksumHeader; + } currentHeaders[checkSumHeaderC] = transmissionChecksumHeader; BulkUploadItem newUploadFile{propagator()->account(), item, fileToUpload, @@ -281,7 +283,11 @@ void BulkPropagatorJob::slotComputeTransmissionChecksum(SyncFileItemPtr item, computeChecksum->setChecksumType(checksumType); connect(computeChecksum, &ComputeChecksum::done, this, [this, item, fileToUpload] (const QByteArray &contentChecksumType, const QByteArray &contentChecksum) { - slotComputeMd5Checksum(item, fileToUpload, contentChecksumType, contentChecksum); + if (propagator()->account()->bulkUploadNeedsLegacyChecksumHeader()) { + slotComputeMd5Checksum(item, fileToUpload, contentChecksumType, contentChecksum); + } else { + slotStartUpload(item, fileToUpload, contentChecksumType, contentChecksum, {}); + } }); connect(computeChecksum, &ComputeChecksum::done, computeChecksum, &QObject::deleteLater);